Skip to content

Fix computation of alpha channel for transparent objects#110

Merged
ManifoldFR merged 2 commits intoSimple-Robotics:mainfrom
ManifoldFR:topic/transparency-fix
Feb 26, 2026
Merged

Fix computation of alpha channel for transparent objects#110
ManifoldFR merged 2 commits intoSimple-Robotics:mainfrom
ManifoldFR:topic/transparency-fix

Conversation

@ManifoldFR
Copy link
Member

@ManifoldFR ManifoldFR commented Feb 26, 2026

Fix WBOIT transparency so that transparent objects over a transparent background have correct alpha in PNG output, and improve color reconstruction in the composite pass.

  • Wrong revealage: output.reveal = 1.0 - alpha * weight produces negative values for most materials (when alpha * weight > 1), which clamp to 0 in the R8_UNORM texture format. The multiplicative blend then leaves the revealTexture unchanged at its clear value of 1.0, so the composite always computes alpha = 1 - reveal = 0. Fixed to output.reveal = alpha.

  • Wrong accumulation denominator: accum.a = alpha caused the composite to reconstruct color * weight instead of color. Fixed to accum.a = alpha * weight.

Before (click the picture; on browsers which support transparency in PNG the robot body will be blank (black))
cdw_screenshot 2026-02-26 17-10-29 +0100
After (robot body is properly transparent)
cdw_screenshot 2026-02-26 18-49-45 +0100

There were already changes to WBOIT in #109 but they weren't enough.

@pierfabre

…in fragment shader

+ weight applies to accum.a, not to revealage (account for change in blend formula)
@ManifoldFR ManifoldFR merged commit 31b07d4 into Simple-Robotics:main Feb 26, 2026
7 checks passed
@ManifoldFR ManifoldFR deleted the topic/transparency-fix branch February 26, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant